package com.kanshu.ksgb.fastread.doudou.module.personal.fragment

import android.os.Bundle
import com.kanshu.ksgb.fastread.doudou.base.baseui.BaseListFragment
import com.kanshu.ksgb.fastread.doudou.common.net.bean.BaseResult
import com.kanshu.ksgb.fastread.doudou.common.net.bean.PageRequestParams
import com.kanshu.ksgb.fastread.doudou.common.net.retrofit.RetrofitHelper
import com.kanshu.ksgb.fastread.doudou.common.net.rx.BaseObserver
import com.kanshu.ksgb.fastread.doudou.module.personal.adapter.MyPrenticesAdapter
import com.kanshu.ksgb.fastread.doudou.module.personal.bean.UserBean
import com.kanshu.ksgb.fastread.doudou.module.personal.presenter.PersonCenterService
import io.reactivex.disposables.Disposable


/**
 * Title:
 * Description:
 * Copyright: Copyright(c)2018
 * Company: 看书网
 * CreateTime: 2018/4/19 17:23
 *
 * @author EvanHe
 * @version 1.0
 */
class PrenticeFragment : BaseListFragment<UserBean>() {


    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        getContentAysnc(PageRequestParams())
    }

    override fun provideAdapter(): MyPrenticesAdapter{
        val adapter = MyPrenticesAdapter(activity!!, mList)
        adapter.setNoMoreDataDesc("")
        return adapter
    }

    override fun getContentAysnc(params: PageRequestParams?) {
        val helper = RetrofitHelper.getInstance()
        helper.createService(PersonCenterService::class.java).getPrenticesList(params)
                .compose(asyncRequest())
                .subscribe(object : BaseObserver<List<UserBean>>() {

                    override fun onResponse(tBaseResult: BaseResult<List<UserBean>>?, t: List<UserBean>?, disposable: Disposable?) {
                        showContent(tBaseResult)
                    }
                })
    }

}